package com.nowcoder.code.lcof;

public class JZ11 {

    public static void main(String[] args) {
        System.out.println(new JZ11().minNumberInRotateArray(new int[]{1,0,1,1,1}));
    }

    public int minNumberInRotateArray(int[] nums) {


        int l = nums.length - 1;
        if (l == 0) {
            return nums[0];
        }
        int s = 0;

        while (s < l) {
            if (nums[l] < nums[l - 1]) {
                return nums[l];
            }

            int m = (s + l) / 2;
            if (nums[m] > nums[l] ) {
                s = m;
            } else if (nums[m] < nums[l] ) {
                l = m;
            } else {
                l--;
            }

        }

        return nums[l];
    }


}
